package itheima03;

import java.util.function.Consumer;
import java.util.function.Predicate;

/**
 * @author xxx
 * @date 2020/12/25 1:33
 * @description
 */
public class Test {
    public static void main(String[] args) {
    //重写函数式接口Consumer中的accept方法，Predicate中的test方法，最后转化为lambda表达式
        String s="不努力没饭吃，努力吃饭";
        cmer(s, new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });

        cmer(s, s1 -> System.out.println(s1));

        pre(s, new Predicate<String>() {
            @Override
            public boolean test(String s) {
                return s.length()>10;
            }
        });

        pre(s, s12 -> s12.length()>10);

    }

    public  static void  cmer(String s, Consumer<String> consumer){
        consumer.accept(s);
    }

    public  static void   pre(String s, Predicate<String>predicate){
        predicate.test(s);
    }
}
